<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>{{firstName + ' ' + lastName}}</h2>
        <h2>{{firstName}} {{lastName}}</h2>
        <h2>{{getFullName()}}</h2>

        <!-- 计算属性: 在使用时不需要加小括号 -->
        <h2>{{fullName}}</h2> 
    </div>

    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                firstName: '苏州',
                lastName: '大学'
            },
            methods: {
                getFullName: function(){
                    return this.firstName + ' ' + this.lastName
                }
            },
            computed:{ //计算属性,后面跟随的函数其实是这个属性的get方法
                fullName: function(){ //由于其是属性,所以在定义名称时尽量按照属性名称进行定义
                    return this.firstName + ' ' + this.lastName
                }
            }
        })
    </script>
</body>
</html>